﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>人员-部门列表</title>
    <link rel="stylesheet" type="text/css" href="themes/default/easyui.css" />
    <link href="../../DataUser/Style/admin/skins/context.standalone.css" rel="stylesheet"
        type="text/css" />
    <script src="../WF/Admin/CCBPMDesigner/js/context.js" type="text/javascript"></script>
    <script type="text/javascript" src="../WF/Scripts/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="../WF/Scripts/jquery/jquery.easyui.min.js"></script>
    <script src="../WF/Scripts/jquery/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />

    <!--<link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../WF/Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../WF/Scripts/jquery/jquery.easyui.min.js"></script>
    <script src="../WF/Scripts/QueryString.js" type="text/javascript"></script>-->
    <!-- 引入新版本的类库. -->
    <!--<script src="../WF/Scripts/config.js" type="text/javascript"></script>
    <script src="../WF/Comm/Gener.js" type="text/javascript"></script>-->

    <!-- 引入新版本的类库. -->
    <script src="../WF/Scripts/config.js" type="text/javascript"></script>
    <script src="../WF/Comm/Gener.js" type="text/javascript"></script>

    <script src="../WF/Scripts/bootstrap/bootstrap-treeview/src/js/bootstrap-treeview.js" type="text/javascript"></script>
    <link href="../WF/Scripts/bootstrap/bootstrap-treeview/src/css/bootstrap-treeview.css" rel="stylesheet" type="text/css" />
    <script src="../WF/Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <link href="../WF/Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../WF/Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" type="text/css" />

    <script src="../WF/Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
    <link href="../WF/Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" type="text/css" />
    <script src="../WF/Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
	<script src="../WF/Scripts/bootstrap/BootstrapUIDialog.js" type="text/javaScript"></script>
    <!--引入zTree树. -->
    <link href="../WF/Scripts/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"
        type="text/css" />
    <script src="../WF/Scripts/zTree_v3/js/jquery.ztree.all.min.js" type="text/javascript"></script>
    <script src="../WF/Scripts/zTree_v3/js/jquery.ztree.core.js" type="text/javascript"></script>
    <script src="../WF/Scripts/zTree_v3/js/jquery.ztree.excheck.js" type="text/javascript"></script>
    <script src="../WF/Scripts/zTree_v3/js/jquery.ztree.exedit.js" type="text/javascript"></script>

    <style type="text/css">
        
       .small-menu {  
        position: absolute;  
        width: 120px;  
        z-index: 99999;  
        border: solid 1px #CCC;  
        background: #EEE;  
        padding: 0px;  
        margin: 0px;  
        display: none;  
    }  
      
    .small-menu li {  
       list-style: none;  
        padding: 0px;  
        margin: 0px;  
    }  
    .small-menu li A {  
        color: #333;  
        text-decoration: none;  
        display: block;  
        line-height: 20px;  
        height: 20px;  
        background-position: 6px center;  
        background-repeat: no-repeat;  
        outline: none;  
        padding: 1px 5px;  
        padding-left: 28px;  
    }  
      
    .small-menu li a:hover {  
        color: #FFF;  
        background-color: #3399FF;  
    }  
      
    .small-menu-separator {  
        padding-bottom:0;  
        border-bottom: 1px solid #DDD;  
    }  
      
    .small-menu LI.edit A { background-image: url(images/page_white_edit.png); }  
    .small-menu LI.cut A { background-image: url(images/cut.png); }  
    .small-menu LI.copy A { background-image: url(images/page_white_copy.png); }  
    .small-menu LI.paste A { background-image: url(images/page_white_paste.png); }  
    .small-menu LI.delete A { background-image: url(images/page_white_delete.png); }  
    .small-menu LI.quit A { background-image: url(images/door.png); }  
    </style>

    <script type="text/javascript">
        var deptNo = "";
        var webUser = new WebUser();
        var setting = {
            view: {
                dblClickExpand: false, //双击节点时，是否自动展开父节点的标识
                showLine: true, //是否显示节点之间的连线
                fontCss: {}, //字体样式函数
                selectedMulti: false //设置是否允许同时选中多个节点
            },
            check: {
                chkboxType: { "Y": "ps", "N": "ps" },
                chkboxType: { "Y": "", "N": "" },
                chkStyle: "checkbox", //复选框类型
                enable: false //每个节点上是否显示 CheckBox
            },
            edit: {
                enable: true,
                editNameSelectAll: true,
                showRemoveBtn: false,
                showRenameBtn: false,
                removeTitle: "remove",
                renameTitle: "rename"
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pid",
                    rootPId: ""
                }
            },
            callback: {

            } //这里是节点点击事件
        };

        $(function () {
            
            $("#pageloading").show();

            var handler = new HttpHandler("BP.WF.HttpHandler.GPMPage");
            var ens = handler.DoMethodReturnJSON("Organization_Init");

            var jsonTree = createJsonToTree(ens);
            zTreeObj = $.fn.zTree.init($("#regionZTree"), setting, jsonTree);
            fillter(zTreeObj); //设置展开前三级
        });
        //设置展开前三级
        function fillter(zTreeObj) {
            //获得树形图对象
            var nodeList = zTreeObj.getNodes(); //展开第一个根节点
            for (var i = 0; i < nodeList.length; i++) { //设置节点展开第二级节点
                zTreeObj.expandNode(nodeList[i], true, false, true);
                //					var nodespan = nodeList[i].children;
                //					for(var j = 0; j < nodespan.length; j++) { //设置节点展开第三级节点
                //						zTreeObj.expandNode(nodespan[j], true, false, true);
                //					}
            }
        }
        //转换ztree需要的数据格式
        var treeJson = [];
        function createJsonToTree(jsonArray) {

            for (var i = 0; i < jsonArray.length; i++) {
                var data = jsonArray[i];
                if (data.No == "" || data.No == undefined)
                    continue;
                treeJson.push({
                    "id": data.No,
                    "pid": data.ParentNo,
                    "name": data.Name,
                    "idx": data.Idx

                });
            }
            return treeJson;
        }

         //更新.
        function Save() {
            var nodes = zTreeObj.getSelectedNodes();
            var empNo = GetQueryString("FK_Emp");
            var deptNo = GetQueryString("FK_DEPT");
            

            //取消人员部门管理关系
            var en = new Entity("BP.GPM.DeptEmp");
            en.SetPKVal(deptNo + "_" + empNo);
            en.Delete();
            //改变主部门
            var emp = new Entity("BP.Port.Emp", empNo);
            var deptNo = nodes[0].id;
            emp.FK_Dept = deptNo;
            emp.Update();
            //增加人员部门管理关系
            var deptEmp = new Entity("BP.GPM.DeptEmp");
            deptEmp.FK_Dept = emp.FK_Dept;
            deptEmp.FK_Emp = emp.No;
            deptEmp.MyPK = emp.FK_Dept + "_" + emp.No;
            deptEmp.Save();
            parent.location.reload();
        }
        //返回.
        function Return() {
            parent.location.reload();
        }
    </script>

    

</head>
<body>

    <div id="pageloading"></div>
    <div id="Btns" data-options="region:'north',noheader:true,split:false,border:false"
                 style="height: 30px; padding: 2px; background-color: #d3d3d34a">
                
                <a id="Btn_Save" href="javaScript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'" onclick="Save()">保存</a>
                <a id="Btn_Return" href="javaScript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-delete'"
                   onclick="Return()">返回</a>
            </div>
    <div style="">
        <div style="width: 100%; height: 95%; overflow: auto;">
             <ul id="regionZTree" class="ztree" data-options="animate:false,dnd:false"></ul>
            
        </div>
    </div>
<div id="Msg"></div>

</body>
</html>
